<?php

namespace app\common\model;

use think\Model;

class DeviceKey extends Model
{
    // 表名
    protected $name = 'device_key';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    // 定义时间戳字段名
    protected $createTime = 'created_at';
    protected $updateTime = 'updated_at';

    const ACTIVATED = 1;
    const UNACTIVATED = 0;

    public static $statusList = [
        '0' => '未激活',
        '1' => '已激活'
    ];

    public function getStatusTextAttr($value, $data)
    {
        return isset(self::$statusList[$data['status']]) ? self::$statusList[$data['status']] : '';
    }

    public function getExpireTime($value, $data)
    {
        return date('Y-m-d H:i:s', $data['expire_time']);
    }

    public function setExpireTime($value)
    {
        return strtotime($value);
    }

}